Class 6 Exam  >  Class 6 Questions  >  What will be the output of the following C co... Start Learning for Free
What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
        enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};
        printf("PEACH = %d\n", PEACH);
    }
  • a)
    PEACH = 3
  • b)
    PEACH = 4
  • c)
    PEACH = 5
  • d)
    PEACH = 6
Correct answer is option 'C'. Can you explain this answer?
Most Upvoted Answer
What will be the output of the following C code? #include <stdio.h...
In enum, the value of constant is defined to the recent assignment from left.
Output:
$ cc pgm1.c
$ a.out
PEACH = 5
Free Test
Community Answer
What will be the output of the following C code? #include <stdio.h...

-

Explanation:

- The code defines an enum with constants ORANGE = 5, MANGO = 6, BANANA = 4, and PEACH = 5.
- Enum assigns values in a sequential order starting from the first initialized constant. So, MANGO will have a value of 6, as it follows ORANGE which has a value of 5.
- BANANA is explicitly assigned a value of 4, so it will have a value of 4.
- Since PEACH does not have an explicit value assigned, it will take the next available value, which in this case is 5.
- Therefore, the output of the code will be "PEACH = 5".
Explore Courses for Class 6 exam
Question Description
What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? for Class 6 2025 is part of Class 6 preparation. The Question and answers have been prepared according to the Class 6 exam syllabus. Information about What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for Class 6 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer?.
Solutions for What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Class 6. Download more important topics, notes, lectures and mock test series for Class 6 Exam by signing up for free.
Here you can find the meaning of What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer?, a detailed solution for What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice What will be the output of the following C code? #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); }a)PEACH = 3b)PEACH = 4c)PEACH = 5d)PEACH = 6Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice Class 6 tests.
Explore Courses for Class 6 exam
Signup to solve all Doubts
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev